import { Provide, Inject } from '@midwayjs/core';
import { PatientDao } from '../dao/patientDao';
import { BigIntService } from './bigInt.service';
import { Context } from '@midwayjs/koa';
import { PatientDTO, UpdatePatientDTO } from '../dto/patient';
import { PageDTO, SearchDTO } from '../dto/page';

@Provide()
export class PatientService {
  @Inject()
  ctx: Context;
  @Inject()
  patientDao: PatientDao;
  @Inject()
  bigIntService: BigIntService;
  //查询患者是否存在
  async findPatient(departmentId: string, name: string, phone: string) {
    return await this.patientDao.findPatient(departmentId, name, phone);
  }
  //通过患者id查询患者是否存在
  async findPatientById(patientId: string) {
    return await this.patientDao.findPatientById(patientId);
  }
  //查询患者id
  async getPatientId(name: string, phone: string) {
    return await this.patientDao.getPatientId(name, phone);
  }
  //创建患者信息
  async createPatient(patientDto: PatientDTO) {
    return await this.patientDao.createPatient(patientDto);
  }
  //用户获取我的患者信息
  async getMyPatient(departmentId: string, pageDto: PageDTO) {
    return await this.patientDao.getMyPatient(departmentId, pageDto);
  }
  //搜索患者信息
  async searchPatients(departmentId: string, searchDto: SearchDTO) {
    return await this.patientDao.searchPatients(departmentId, searchDto);
  }
  //管理员获取所有患者信息
  async getAllPatient(pageDto: PageDTO) {
    return this.bigIntService.bigInt(
      await this.patientDao.getAllPatient(pageDto)
    );
  }
  //修改患者信息
  async updatePatientInfo(updatePatientDto: UpdatePatientDTO) {
    return await this.patientDao.updatePatientInfo(updatePatientDto);
  }
}
